package si.yun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import si.yun.dao.OpeHomeDao;
import si.yun.service.OpeService;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName OpeHomeServiceImpl
 * @description:
 * @Author 李军瑶
 * @Date 2021/7/29 16:19
 **/
@Service
public class OpeHomeServiceImpl implements OpeService {

    @Autowired
    private OpeHomeDao dao;

    /*
    * @Description 统计昨日订单数和昨日销售额度
    * @return java.lang.Integer
    * @Date 19:34 2021/7/29
    */
    @Override
    public List<Map<String,Object>> getYesterdayOrder() {
        List<Map<String,Object>> yesterdayOrder = dao.getYesterdayOrder();
        return yesterdayOrder;
    }

    /*
     * @Description 统计全部订单数和销售总额
     * @return java.lang.Integer
     * @Date 16:20 2021/7/29
     */
    @Override
    public List<Map<String,Object>> getAllOrders() {
        List<Map<String,Object>> allOrders = dao.getAllOrders();
        return allOrders;
    }

    /*
    * @Description 统计待审核课程
    * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
    * @Date 8:59 2021/7/30
    */
    @Override
    public List<Map<String, Object>> getAuditCourses(Integer AuditCourses) {
        List<Map<String, Object>> auditCourses = dao.getAuditCourses(AuditCourses);
        return auditCourses;
    }

    /*
    * @Description 统计待审核商品
    * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
    * @Date 9:58 2021/7/30
    */
    @Override
    public List<Map<String, Object>> getAuditProduct(Integer AuditProduct) {
        List<Map<String, Object>> auditProduct = dao.getAuditProduct(AuditProduct);
        return auditProduct;
    }

    /*
    * @Description 统计时间段内所有订单——统计图
    * @return java.util.List<java.lang.Integer>
    * @Date 9:07 2021/8/2
    */
    @Override
    public List<Integer> getSpecifyDate(String SpecifyDate) {
        String DataTime1=SpecifyDate+" 0:00:00";
        String DataTime2=SpecifyDate+" 3:00:00";
        String DataTime3=SpecifyDate+" 6:00:00";
        String DataTime4=SpecifyDate+" 9:00:00";
        String DataTime5=SpecifyDate+" 12:00:00";
        String DataTime6=SpecifyDate+" 15:00:00";
        String DataTime7=SpecifyDate+" 18:00:00";
        String DataTime8=SpecifyDate+" 21:00:00";
        String DataTime9=SpecifyDate+" 0:00:00";
        //定义list集合添加数据
        List list=new ArrayList();
        list.add(DataTime1);
        list.add(DataTime2);
        list.add(DataTime3);
        list.add(DataTime4);
        list.add(DataTime5);
        list.add(DataTime6);
        list.add(DataTime7);
        list.add(DataTime8);
        list.add(DataTime9);

        List list1 = new ArrayList();
        for(int i = 1; i<list.size(); i++){
            String minDateTime= (String) list.get(i-1);
            String maxDateTime= (String) list.get(i);
            Integer timeOrder = dao.getTimeOrder(minDateTime, maxDateTime);
            list1.add(timeOrder);
        }
        return list1;
    }

    @Override
    public Integer getOrdersNumber(String yesterday, String today) {
        String DataTime1=yesterday+" 0:00:00";
        String DataTime2=today+" 0:00:00";
        Integer timeOrder = dao.getTimeOrder(DataTime1, DataTime2);
        return timeOrder;
    }
}


